<template>


<van-nav-bar
  title="京东登录"
  left-text="返回"
  left-arrow
  @click-left="$router.go(-1)"
/>
<van-form @submit="onSubmit">
  <van-cell-group inset>
    <van-field
      v-model="password"
      name="password"
      label="请输入密码"
      type="password"
      placeholder="至少6位,包括数字字母下划线"
      :rules="[{ pattern, message: '请输入正确内容' }]"
    />
 </van-cell-group>
 <div style="margin: 16px;">
    <van-button round block type="primary" native-type="submit">
      提交
    </van-button>
 </div>
</van-form>

</template>

<script setup lang='ts'>
import { useRouter } from 'vue-router';
import { ref } from 'vue';
import { Dialog } from 'vant';
import { useUserStore } from '@/store/userstore';
import {zhucecg}from '@/api/zc'

const useStore = useUserStore();
console.log( 11,useStore.userId);
const router = useRouter()
const password= ref('')
const pattern =/^\S*(?=\S{6,})(?=\S*\d)(?=\S*[A-Z])(?=\S*[a-z])(?=\S*[!@#$%^&*? ])\S*$/;

const onSubmit = ()=>{
    zhucecg({tel:useStore.userId,password:password.value}).then((res:any)=>{
        console.log(res);
        if(res.code=='200'){
                Dialog.confirm({
               title: '标题',
               message:
               '注册成功，跳到登录页？',
        })
         .then(() => {
       // on confirm
       router.push('/login')
       // useStore.setUserId(values.userid)
        })
       .catch(() => {
        // on cancel
       });
      }
    })

   
}

</script>
<style scoped>

</style>